package com.ruoyi.web.controller.consumer;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.consumer.domain.query.VRoomHyQuery;
import com.ruoyi.consumer.service.IVRoomHyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 供热用户实现类
 * @author lisongtao
 * @date 2023/10/22 11:33
 */
@RestController
@RequestMapping("/vRoomHy")
public class VRoomHyController extends BaseController {


    @Autowired
    private IVRoomHyService vRoomHyService;


    /**
     * 获取所有的小区信息
     */
    @PostMapping("/selectFParentList")
    public AjaxResult selectFParentList() {
        return AjaxResult.success(vRoomHyService.selectFParentList());
    }

    /**
     * 根据小区名称查询供热楼座/区域名称、单元、房间信息
     */
    @PostMapping("/selectRegionList")
    public AjaxResult selectRegionList(@RequestBody VRoomHyQuery vRoomHyQuery) {
        return AjaxResult.success(vRoomHyService.selectRegionList(vRoomHyQuery.getParent()));
    }

    /**
     * 查询单元和房间信息
     */
    @PostMapping("/selectUnitAndRoomList")
    public AjaxResult selectUnitAndRoomList(@RequestBody VRoomHyQuery vRoomHyQuery) {
        return AjaxResult.success(vRoomHyService.selectUnitAndRoomList(vRoomHyQuery.getParent(), vRoomHyQuery.getRegion()));
    }


    /**
     * 查询供热用户信息
     */
    @PostMapping("/queryInformationHeatUser")
    public AjaxResult queryInformationHeatUser(@RequestBody VRoomHyQuery vRoomHyQuery) {
        return AjaxResult.success(vRoomHyService.queryInformationHeatUser(vRoomHyQuery));
    }

    /**
     * 绑定供热用户
     */
    @Log(title = "用户房产绑定关系", businessType = BusinessType.INSERT)
    @PostMapping("/boundHeatUser")
    public AjaxResult boundHeatUser(@RequestBody VRoomHyQuery vRoomHyQuery) {
        vRoomHyService.boundHeatUser(vRoomHyQuery);
        return AjaxResult.success();
    }


}
